package com.zhongyu.controller;

import com.zhongyu.pojo.Log;
import com.zhongyu.pojo.OrderDetail;
import com.zhongyu.service.LogService;
import com.zhongyu.vo.LogVo;
import com.zhongyu.vo.PageResult;
import com.zhongyu.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/sys/log/")
public class LogController {

    @Resource
    private LogService logService;

    @PostMapping("/add2")
    public ResultVo add2(@RequestBody OrderDetail orderDetail, HttpSession session){
        try {
            logService.add(orderDetail,session);
            return ResultVo.success("驳回成功！");
        }catch (Exception ex){
            return ResultVo.failure("驳回失败！",ex);
        }
    }
    @GetMapping("/search/{pageNo}/{pageSize}")
    public ResultVo search(@PathVariable Integer pageNo, @PathVariable Integer pageSize, LogVo logVo){
        PageResult pageResult=logService.searchAll(pageNo,pageSize,logVo);
        return ResultVo.success(pageResult);

    }
    @GetMapping("/list")
    public ResultVo list(){
        List<Log> list=logService.searchAll();
        return ResultVo.success(list);
    }
}
